var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
    })(e, t);
}, function(e, t) {
    function n() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
    new n());
}), a = this && this.__decorate || function(e, t, o, n) {
    var s, i = arguments.length, r = i < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, o) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n); else for (var a = e.length - 1; 0 <= a; a--) (s = e[a]) && (r = (i < 3 ? s(r) : 3 < i ? s(t, o, r) : s(t, o)) || r);
    return 3 < i && r && Object.defineProperty(t, o, r), r;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("PlayerModel"), s = e("LoadManager"), c = cc._decorator, l = c.ccclass, d = (c.property, 
function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.skeleton = null, e.skeletonPath = null, e.model = null, e.isEffect = !1, 
        e.isDestory = !1, e.isLoad = !1, e;
    }
    return i(e, t), e.prototype.start = function() {}, e.prototype.init = function(e) {
        this.model = e;
    }, e.prototype.doFire = function() {
        switch (this.model.fire) {
          case r.FireType.暴力枪:
            break;

          case r.FireType.狙击枪:
            this.playSkeleton("skeleton/game/fire狙击枪/skeleton", "animation", this.node.parent.parent);
            break;

          case r.FireType.加特林:
            this.playSkeleton("skeleton/game/fire加特林2/skeleton");
            break;

          case r.FireType.闪电枪:
            break;

          case r.FireType.导弹枪:
            this.playSkeleton("skeleton/game/fire导弹枪/skeleton", "huojianpao1", this.node.parent.parent);
            break;

          case r.FireType.激光枪:
            break;

          default:
            this.playSkeleton("skeleton/game/fire通用枪/skeleton");
        }
    }, e.prototype.playSkeleton = function(n, i, e) {
        var r = this;
        void 0 === i && (i = "animation"), void 0 === e && (e = this.node), null == this.skeleton && (this.skeleton = new cc.Node().addComponent(sp.Skeleton)), 
        e != this.node && (this.skeleton.node.setPosition(e.convertToNodeSpaceAR(this.node.convertToWorldSpaceAR(cc.Vec2.ZERO))), this.skeleton.premultipliedAlpha = false,
        this.skeleton.node.angle = this.node.angle), this.skeleton.node.setParent(e), this.skeletonPath == n ? this.startFire(i) : this.isLoad || (this.isLoad = !0, 
        s.default.getInstance().loadRes({
            url: n,
            type: sp.SkeletonData
        }).then(function(e) {
            r.isLoad = !1;
            try {
                r.skeletonPath = n, r.skeleton.skeletonData = e;
                var t = 1, o = r.model.IDLE;
                r.skeleton.getState().data.skeletonData.animations.forEach(function(e) {
                    e.name == i && e.duration > o && (t = e.duration / o, o = e.duration);
                }), r.skeleton.timeScale = t, r.startFire(i);
            } catch (e) {
                cc.error(e), r.skeleton && (r.skeleton.node.destroy(), r.skeleton = null);
            }
        }));
    }, e.prototype.startFire = function(e) {
        var t = this;
        void 0 === e && (e = "animation"), this.isLoad || this.skeleton && e && (this.isEffect || (this.isEffect = !0, 
        this.skeleton.node.opacity = 255, this.skeleton.setAnimation(0, e, !1), this.skeleton.setCompleteListener(function() {
            t.isEffect = !1, t.skeleton.node.opacity = 0;
        })));
    }, e.prototype.stopFire = function() {
        this.isDestory && (this.isDestory = !0, this.isEffect = !1, this.skeleton && (this.skeleton.node.destroy(), 
        this.skeleton = null));
    }, a([ l ], e);
}(cc.Component));

n.default = d;